<template>
  <div class="box">
    <van-nav-bar title="订单详情" left-arrow @click-left="onClickLeft" class="header">
      <template #right>
        <van-icon name="ellipsis" @click="showMark" />
      </template>
    </van-nav-bar>
    <van-overlay :show="show">
      <div class="wrapper" @click="closeMark">
        <div class="block">
          <div @click="goHome">
            <van-icon name="wap-home-o" class="block_icon" />
            <span>主页</span>
          </div>
          <div @click="goUser">
            <van-icon name="contact" class="block_icon" />
            <span>我的聚橙</span>
          </div>
        </div>
      </div>
    </van-overlay>
    <div class="orderDetails_a">
      <div class="orderDetails_a_bj">
        <h4 v-if="orderDetailsList.status === '0'">待支付</h4>
        <h4 v-else-if="orderDetailsList.status === '1'">待收货</h4>
        <h4 v-else>去评价</h4>
      </div>
      <div class="orderDetails_a_content">
        <div class="orderDetails_a_content_top">
          <p v-if="orderDetailsList.orderlist">{{orderDetailsList.orderlist[0].name}}</p>
          <div>
            <van-icon name="underway-o" class="orderDetails_a_icon" />
            <span v-if="orderDetailsList.orderlist">{{orderDetailsList.orderlist[0].start_show_time.substring(0,10)}}&nbsp;{{orderDetailsList.orderlist[0].show_time_bottom}}&nbsp;{{orderDetailsList.orderlist[0].start_show_time.substring(11,16)}}</span>
          </div>
          <div>
            <van-icon name="location-o" class="orderDetails_a_icon" />
            <span v-if="orderDetailsList.orderlist">{{orderDetailsList.orderlist[0].city_name}}&nbsp;|&nbsp;{{orderDetailsList.orderlist[0].venue_name}}</span>
          </div>
        </div>
        <div class="orderDetails_a_content_bottom">
          <span v-if="orderDetailsList.orderlist">{{orderDetailsList.orderlist[0].num}}&nbsp;张</span>
        </div>
      </div>
    </div>
    <div class="orderDetails_b">
      <div>
        <span>配送方式&nbsp;:&nbsp;&nbsp;&nbsp;快递</span>
      </div>
      <div @click="goAddress" v-if="orderDetailsList.userinfo">
        <span v-if="orderDetailsList.userinfo.name === ''">请填写收货人信息</span>
        <span v-else class="address_msg">
          <i>{{orderDetailsList.userinfo.name}}&nbsp;{{orderDetailsList.userinfo.tel}}</i>
          <i>{{orderDetailsList.userinfo.province + orderDetailsList.userinfo.city + orderDetailsList.userinfo.county}}</i>
        </span>
        <van-icon name="arrow" class="cart_b_icon" />
      </div>
      <p>
        <van-icon name="warning-o" class="icon" />
        发货说明：下单成功开演前1个月内发货，请耐心等待
      </p>
    </div>
    <div class="orderDetails_c">
      <div>
        <span>商品金额</span>
        <span>￥{{orderDetailsList.totalprice + '.00'}}</span>
      </div>
      <div>
        <span>运费</span>
        <span>+￥0.00</span>
      </div>
      <div>
        <span>活动/优惠</span>
        <span class="activeColor">-￥0.00</span>
      </div>
      <div>
        <span>账户余额</span>
        <span class="activeColor">-￥0.00</span>
      </div>
      <div>
        <span></span>
        <span>应付小计:<b class="activeColor">￥{{orderDetailsList.totalprice + '.00'}}</b></span>
      </div>
    </div>
    <div class="orderDetails_d">
      <div>
        <span>订单留言</span>
        <span>{{orderDetailsList.Remarks}}</span>
      </div>
      <div>
        <span>支付方式</span>
        <span>{{orderDetailsList.PaymentMethod}}</span>
      </div>
    </div>
    <div class="orderDetails_e">
      <div>
        <span v-if="orderDetailsList">订单号：{{orderDetailsList.orderid.substring(6, 23)}}</span>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { Icon, NavBar, Overlay } from 'vant'
import { getOrderDetailsList } from '@/api'
Vue.use(NavBar)
Vue.use(Icon)
Vue.use(Overlay)
export default {
  data () {
    return {
      show: false,
      orderid: '',
      orderDetailsList: ''
    }
  },
  mounted () {
    this.orderid = this.$route.query.orderid
    getOrderDetailsList({
      orderid: this.orderid
    }).then(res => {
      this.orderDetailsList = res.data.data
      // console.log(this.orderDetailsList.userinfo)
    })
    // 解决路由传参跳转不在头部问题！！
    this.$router.afterEach(() => {
      window.scrollTo(0, 0)
    })
  },
  methods: {
    onClickLeft () {
      this.$router.go(-1)
    },
    showMark () {
      this.show = true
    },
    closeMark () {
      this.show = false
    },
    goHome () {
      this.$router.push('/home')
    },
    goUser () {
      if (localStorage.getItem('loginState') !== 'ok') {
        this.$router.push('/login')
      } else {
        this.$router.push('/user')
      }
    },
    goAddress () {
      this.$router.push({ path: '/addressList', query: { orderid: this.orderid } })
    }
  }
}
</script>

<style lang="scss" scoped>
.header {
  position: fixed;
  top: 0;
  z-index: 100;
  background: white!important;
}
.wrapper {
  display: flex;
  position: relative;
  height: 100%;
}
.block {
  width: 1.4rem;
  height: 0.9rem;
  position: absolute;
  top: 0.44rem;
  right: 0.05rem;
  border-radius: 0.05rem;
  background-color: #fff;
  div {
    width: 100%;
    height: 0.44rem;
    line-height: 0.44rem;
    .block_icon {
      font-size: 0.2rem;
      margin: 0 0.13rem;
      float: left;
      margin-top: 0.1rem;
    }
    span {
      float: left;
    }
  }
  div:nth-of-type(1) {
    border-bottom: 1px solid #f2f2f2;
  }
}
.orderDetails_a {
  margin-top: 0.44rem;
  width: 100%;
  height: 3.1rem;
  padding-bottom: 0.1rem;
  position: relative;
  .orderDetails_a_bj {
    width: 100%;
    overflow: hidden;
    height: 2.75rem;
    background-image: linear-gradient(-50deg, #ff4d4a 0%, #ff9a34 100%),linear-gradient(#ff6743, #ff6743);
    h4 {
      width: 100%;
      height: 0.34rem;
      line-height: 0.34rem;
      text-align: center;
      margin-top: 0.3rem;
      color: #fff;
      font-size: 0.2rem;
      font-weight: normal;
    }
  }
  .orderDetails_a_content {
    width: calc(100% - 0.3rem);
    height: 2.05rem;
    margin: 0.1rem 0.15rem 0 0.15rem;
    background: white;
    border-radius: 0.05rem;
    position: absolute;
    top: 0.8rem;
    box-shadow: 0 4px 4px #eeeeee;
    .orderDetails_a_content_top {
      width: 100%;
      height: 1.1rem;
      border-bottom: 1px dashed #eeeeee;
      p {
        margin-top: 0.27rem;
        margin-bottom: 0.17rem;
        padding: 0 0.2rem;
        height: 0.4rem;
        line-height: 0.2rem;
        font-size: 0.18rem;
        font-weight: bold;
        color: #232323;
        overflow : hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      div {
        width: 100%;
        height: 0.25rem;
        line-height: 0.2rem;
        box-sizing: border-box;
        padding: 0 0.2rem 0.05rem 0.2rem;
        .orderDetails_a_icon {
          line-height: 0.2rem;
          font-size: 0.14rem;
          float: left;
        }
        span {
          width: 90%;
          margin-left: 0.05rem;
          line-height: 0.2rem;
          color: #232323;
          float: left;
          overflow: hidden;
          text-overflow:ellipsis;
          white-space: nowrap;
        }
      }
    }
    .orderDetails_a_content_bottom {
      width: 100%;
      height: 0.6rem;
      span {
        height: 0.84rem;
        margin-left: 0.2rem;
        line-height: 0.6rem;
        font-size: 0.16rem;
        color: #232323;
      }
    }
  }
}
.orderDetails_b {
  width: 100%;
  height: 1.7rem;
  box-sizing: border-box;
  padding: 0 0.15rem;
  border-bottom: 0.12rem solid #eeeeee;
  div {
    width: 100%;
    height: 0.56rem;
    border-bottom: 1px solid #ebebeb;
    line-height: 0.56rem;
    span {
      font-size: 0.16rem;
      color: #232323;
      float: left;
    }
    .address_msg {
      float: left;
      width: 2.3rem;
      height: 0.56rem;
      padding: 0.08rem 0;
      i {
        float: left;
        width: 100%;
        height: 0.2rem;
        margin: 0;
        font-size: 0.14rem;
        line-height: 0.24rem;
        color: #232323;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space: nowrap;
      }
    }
    .cart_b_icon {
      font-size: 0.14rem;
      float: right;
      line-height: 0.56rem;
    }
    b {
      float: right;
      background: #ff6743;
      border-radius: 0.03rem;
      height: 0.18rem;
      padding: 0 0.03rem;
      font-size: 0.12rem;
      font-weight: normal;
      margin-top: 0.19rem;
      line-height: 0.18rem;
      margin-right: 0.05rem;
      color: white;
    }
  }
  div:nth-of-type(2) {
    span {
      font-size: 0.14rem;
      color: #666666;
    }
  }
  p {
    width: 100%;
    height: 0.16rem;
    margin: 0.15rem 0;
    line-height: 0.16rem;
    font-size: 0.12rem;
    color: #999999;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
}
.orderDetails_c {
  width: 100%;
  height: 2.87rem;
  padding: 0 0.15rem;
  border-bottom: 0.12rem solid #eeeeee;
  div:nth-of-type(1) {
    span {
      color: #232323;
      font-size: 0.16rem;
    }
  }
  div {
    width: 100%;
    height: 0.55rem;
    border-bottom: 1px solid #ebebeb;
    line-height: 0.55rem;
    color: #666666;
    span:nth-of-type(1) {
      float: left;
      font-size: 0.14rem;
    }
    span:nth-of-type(2) {
      float: right;
      font-size: 0.14rem;
      b {
        font-weight: normal;
      }
    }
    .activeColor {
      color: #ff6743;
    }
  }
}
.orderDetails_d {
  width: 100%;
  height: 1.22rem;
  padding: 0 0.15rem;
  border-bottom: 0.12rem solid #eeeeee;
  div {
    width: 100%;
    height: 0.55rem;
    line-height: 0.55rem;
    color: #666666;
    font-size: 0.14rem;
    border-bottom: 1px solid #ebebeb;
    span:nth-of-type(1) {
      float: left;
    }
    span:nth-of-type(2) {
      float: right;
    }
  }
}
.orderDetails_e {
  width: 100%;
  height: 1.55rem;
  padding: 0 0.15rem;
  border-bottom: 1rem solid #eeeeee;
  span {
    line-height: 0.55rem;
    text-align: left;
    color: #232323;
    font-size: 0.14rem;
  }
}
/deep/ .van-nav-bar {
  border-bottom: 1px solid #ebebeb;
}
/deep/ .van-icon-ellipsis {
  font-size: 0.2rem;
  color: #232323;
}
/deep/ .van-icon-arrow-left {
  font-size: 0.2rem;
  color: #232323;
}
</style>
